package com.ck.daoImpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ck.dao.ChapterDAO;
import com.ck.domain.Chapter;

public class ChapterDAOImpl extends SqlMapClientDaoSupport implements ChapterDAO {

	public List<Chapter> getAllChapter() {
		return (List<Chapter>)getSqlMapClientTemplate().queryForList("getAllChapter");
	}

	public Chapter getChapterById(Integer id) {
		return (Chapter) getSqlMapClientTemplate().queryForObject("getChapterById",id);
	}

	public Chapter getChapterByName(String name) {
		return (Chapter) getSqlMapClientTemplate().queryForObject("getChapterByName",name);
	}

	public List<Chapter> getChapterBySubject(Integer subject) {
		return (List<Chapter>) getSqlMapClientTemplate().queryForList("getChapterBySubject",subject);
	}

	public void addNewChapter(Chapter chapter) {
		getSqlMapClientTemplate().insert("addNewChapter", chapter);
	}

	public void updateChapterInfo(Chapter chapter) {
		getSqlMapClientTemplate().update("updateChapterInfo", chapter);
	}

}
